package com.ltz.web.well;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ltz.model.Page;
import com.ltz.model.User;
import com.ltz.model.WellBasicData;
import com.ltz.service.well.WellGroupService;
import com.ltz.service.well.WellService;

@Controller
@RequestMapping("/well")
public class WellController {
	@Resource
	private WellService wellService;

	@ResponseBody
	@RequestMapping("loadList")
	public Page loadList(Page page,String queryStr){
		return wellService.loadList(page,queryStr);
	}
	@RequestMapping(value="doAddWell",method=RequestMethod.POST)
	public String doAddWell(WellBasicData w,HttpServletRequest request){
		String s=request.getParameter("dateFinishWell");
//		w.setDateFinishWell(s);//总是有“，”找不到原因所以手动更正下；
		User user=(User) request.getSession().getAttribute("user");
		wellService.doAddWell(user, w);
		return "/save_ok";
	}
	@RequestMapping(value="doUpdateWell",method=RequestMethod.POST)
	public String doUpdateWell(HttpServletRequest request,WellBasicData w){
		User user=(User) request.getSession().getAttribute("user");
		String s=request.getParameter("dateFinishWell");
//		w.setDateFinishWell(s);//总是有“，”找不到原因所以手动更正下；
		wellService.doUpdateWell(user,w);
		return "/save_ok";
	}
	@ResponseBody
	@RequestMapping("doDeleteWell")
	public Boolean doDeleteWellGroup(int wellId){
		return wellService.doDeleteWell(wellId);
	}
}
